function GetDateStr(AddDayCount) {
  // AddDayCount参数为以今天为标准,往前往后n天
  // -10为十天前  10为10天后
  let dd = new Date();
  dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
  let y = dd.getFullYear();
  let m =
    dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1; //获取当前月份的日期，不足10补0
  let d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号，不足10补0
  return y + "-" + m + "-" + d;
}

// example1
console.log("十天前:" + GetDateStr(-10));
console.log("三月前:" + GetDateStr(-90));
console.log("一月前:" + GetDateStr(-30));
console.log("昨天:" + GetDateStr(-1));
console.log("今天:" + GetDateStr(0));
console.log("明天:" + GetDateStr(1));
console.log("后天:" + GetDateStr(2));
console.log("一月后:" + GetDateStr(30));
console.log("三月后:" + GetDateStr(90));
console.log("半年后:" + GetDateStr(180));
